﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Exhibition.Dao.ViewModel;
using Exhibition.Service;

namespace Exhibition.UserCenter
{
    public partial class VisitSign : BaseUserPage
    {
        StringBuilder sb = new StringBuilder();
        List<ProductClassModel> pclassList = new List<ProductClassModel>();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetUserData();
                BuildProduct();
            }
        }

        private void BuildProduct()
        {

            BuildSon(0);
            if (pclassList != null) {
                foreach (var p in pclassList) { 
                       sb.Append(" <span>");
                      sb.AppendFormat("  <input type=\"checkbox\"  name='chkcls' value=\"{0}\"/>",p.Id);
                      sb.AppendFormat("</span><span class=\"mr\">{0}</span>",p.ClassName);
                }
            }
            ltrProducts.Text = sb.ToString();


        }

        public void BuildSon(int pid) {
            List<ProductClassModel> pcls = CenterService.productClassService.GetListByPid(pid, stmd.Id);
            pclassList.AddRange(pcls);
        }



        private void GetUserData()
        {
            if (LoginUser != null) {
                Email.Text = LoginUser.Email;
                Position.Text = LoginUser.Position;
                Mobile.Text = LoginUser.Mobile;
                if (LoginUser.compMdl != null)
                {
                    ltrCompName.Text = LoginUser.compMdl.CompName;
                    ltrCompAddr.Text = LoginUser.compMdl.CompAddr;
                    ContactMan.Text = LoginUser.compMdl.Contact;
                    Phone.Text=LoginUser.compMdl.PhoneStart +"-"+LoginUser.compMdl.PhoneNum;
                    Fax.Text = LoginUser.compMdl.FaxStart + "-" + LoginUser.compMdl.FaxNum;
                }
            }
        }
    }
}